<?php
namespace app\admin\controller;
use app\common\lib\Redis;
use app\common\lib\redis\Predis;
use app\common\lib\Util;

class Live{
    public function push()
    {

        if(empty($_GET))
        {
          return  Util::show(config('code.error'),'error');
        }
        $teams = [
            1=>[
                'name'=>"马刺",
                'logo'=>'/live/imgs/team1.png'
            ],
            4=>[
                'name'=>'火箭',
                'logo'=>'/live/imgs/team2.png'
            ],
        ];
        $data = [
            'type'=>intval($_GET['type']),
            'title'=>!empty($teams[$_GET['team_id']]['name'])?$teams[$_GET['team_id']]['name']:'直播员',
            'logo'=>!empty($teams[$_GET['team_id']]['logo'])?$teams[$_GET['team_id']]['logo']:'',
            'content'=>!empty($_GET['content'])?$_GET['content']:'',
            'image'=>!empty($_GET['image'])?$_GET['image']:''
        ];
        //获取连接的用户
        //赛况的基本信息入库 数据组装好 push到直播界面
        $taskData = [
            'method'=> 'pushLive',
            'data' =>$data
        ];
        $_POST['http_server']->task($taskData);
        return Util::show(config('code.success'),'OK！');

    }
    /*
    public  function reverseBits($str)
    {
        $len =0;
        while ($str){
            $len = $len<<1;
            $len = $str & 1 | $len;
            $str = $str >>1;
        }
        return $len;
    }*/
}
